/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package submarines;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.xml.bind.JAXBException;

/**
 *
 * @author sshiran
 */
public class OnlineHumanPlayer extends HumanPlayer{
    HttpSession session;
    Date last;
    
    OnlineHumanPlayer(String userName, int userScore)
    {
        super(userName, userScore);
        session = null;
    }
    
    public OnlineHumanPlayer(String userName)
    {
        super(userName, 0);
        session = null;
    }
    
    public OnlineHumanPlayer(String name, List<SubmarinesBindings.Boat> xmlBoats, SubmarinesBindings.Board b) throws JAXBException {
        super(name, xmlBoats, b);
        session = null;
    }
        
    public void setSession(HttpServletRequest s) {
        session = s.getSession(true);
    }
    
    public String getSessionId()
    {
        if (session == null)
            return null;
        return session.getId();
    }
    
    public void setDeathCause(int num)
    {
        this.deathCause = num;
    }
    public boolean isReady() {
        if (session == null)
            return false;
        if (myBoard == null)
            return false;   
        if(myBoard.subsLeft<Config.SUBMARINES.length)
            return false;
        return true;
    }

    public void setSessionTime() {
        last = new Date();
    }
}
